import Http, {ReqProps} from "@/common/http";
import {SelectTreeData} from "@/components/ant-ext/HTreeSelect";


export type SysOrgTree = {
    key: string
    pId: string
    title: string
    children: SysOrgTree[]
}


class SysOrg {
    AddOrgRoot = "addOrgRoot"

    treeView(props: ReqProps<SysOrgTree[]>) {
        Http.doGet("/api/org/tree", props)
    }

    doEdit(props: ReqProps<void>) {
        Http.doPost("/api/org/edit", props)
    }

    doResort(props: ReqProps<void>) {
        Http.doPost("/api/org/resort", props)
    }

    doMove(props: ReqProps<void>) {
        Http.doPost("/api/org/move", props)
    }

    deleteById(props: ReqProps<void>) {
        Http.doPost("/api/org/delete", props)
    }

    selectTree(props: ReqProps<SelectTreeData[]>) {
        Http.doGet("/api/org/selectTree", props)
    }
}

// eslint-disable-next-line import/no-anonymous-default-export
export default new SysOrg()